/*
 * @lc app=leetcode.cn id=504 lang=javascript
 *
 * [504] 七进制数
 */

// @lc code=start
/**
 * @param {number} num
 * @return {string}
 */
var convertToBase7 = function(num) {
   return num.toString(7)
};
// @lc code=end

var convertToBase7 = function(num) {
    if(num==0)return "0"
    let copy=Math.abs(num)
    let s=""
    while(copy){
        let v=copy%7
        let u=(copy/7)|0
        s=v+s
        copy=u
    }
    return num>=0?s:('-'+s)
};